
J.R.Pc = J.R.Ej.extend({
    o: function(a, b) {
        var c = a.length;
        this.ae = Array(c);
        for (var d, f, g = 0; g < c; g += 1) if (d = a[g], f = new J.R.Ar(d), this.ae[g] = f, !b) if (0 === g) {
            if (0 === d.length) break;
            f.Zh(d) || d.reverse()
        } else 0 !== d.length && f.Zh(d) && d.reverse()
    },
    Ub: function() {
        if (0 === this.ae.length) return [Infinity, Infinity, -Infinity, -Infinity];
        if (!this.Ic) {
            for (var a = this.ae[0].Ub(), b = 1; b < this.ae.length; b += 1) {
                var c = this.ae[b].Ub();
                J.g.Du(a, c) || J.g.extend(a, c)
            }
            this.Ic = a
        }
        return this.Ic
    },
    dJ: function() {
        return this.ae
    },
    kd: function() {
        return J.R.Db.sl
    },
    Hd: function(a) {
        for (var b = this.ae,
                 c, d = 0,
                 f = b.length; d < f && (c = b[d].Hd(a), 0 < d && (c = !c), c); d += 1);
        return c
    }
});
J.R.tn = J.R.Ej.extend({
    o: function(a) {
        var b = a.length;
        this.Rc = Array(b);
        for (var c = 0; c < b; c += 1) {
            var d = new J.R.Pc(a[c]);
            this.Rc[c] = d
        }
    },
    Ub: function() {
        if (!this.Ic) {
            for (var a = [Infinity, Infinity, -Infinity, -Infinity], b = this.Rc, c = 0, d = b.length; c < d; c += 1) J.g.extend(a, b[c].Ub());
            this.Ic = a
        }
        return this.Ic
    },
    tp: function() {
        return this.Pa
    },
    kd: function() {
        return J.R.Db.rl
    },
    GD: function() {
        return this.Rc
    },
    Hd: function(a) {
        for (var b = !1,
                 c = 0,
                 d = this.Rc.length; c < d; c += 1) if (this.Rc[c].Hd(a)) {
            b = !0;
            break
        }
        return b
    }
});
J.R.zi = J.R.Ej.extend({
    o: function(a) {
        this.Pa = a
    },
    Ub: function() {
        if (!this.Ic) {
            for (var a = [Infinity, Infinity, -Infinity, -Infinity], b = 0, c = this.Pa.length; b < c; b += 1) J.g.Vu(a, this.Pa[b]);
            this.Ic = a
        }
        return this.Ic
    },
    tp: function() {
        return this.Pa
    },
    kd: function() {
        return J.R.Db.nn
    },
    ID: function() {
        return this.Pa.length
    },
    om: function(a) {
        for (var b = this.Pa,
                 c = Infinity,
                 d = 0,
                 f = 1,
                 g = b.length; f < g; d = f, f += 1) c = Math.min(c, J.ug.NG(a, [b[d], b[f]]));
        return Math.sqrt(c)
    }
});
J.R.Ar = J.R.zi.extend({
    kd: function() {
        return J.R.Db.yr
    },
    Zh: J.ug.Zh,
    Hd: function(a) {
        return J.ug.Hd(a, this.Pa)
    }
});
J.R.sn = J.R.Ej.extend({
    o: function(a) {
        var b = a.length;
        this.Rc = Array(b);
        for (var c = 0; c < b; c += 1) {
            var d = new J.R.zi(a[c]);
            this.Rc[c] = d
        }
    },
    GD: function() {
        return this.Rc
    },
    Ub: function() {
        if (!this.Ic) {
            for (var a = [Infinity, Infinity, -Infinity, -Infinity], b = this.Rc, c = 0, d = b.length; c < d; c += 1) J.g.extend(a, b[c].Ub());
            this.Ic = a
        }
        return this.Ic
    },
    tp: function() {
        return this.Pa
    },
    kd: function() {
        return J.R.Db.qn
    },
    ID: function() {
        return this.Pa.length
    },
    om: function(a) {
        for (var b = Infinity,
                 c = 0,
                 d = this.Rc.length; c < d; c += 1) b = Math.min(b, this.Rc[c].om(a));
        return b
    }
});
J.ba.gd = J.ba.lh.extend({
    o: function(a, b) {
        arguments.callee.Ja.apply(this, arguments);
        this.hC = a;
        this.D("options", a);
        this.D("geodesic", a);
        this.D("path", a);
        this.D("noSelect", a);
        this.Nh();
        this.D("display", b);
        b.c("zoomend", this.Eh, this)
    },
    geodesicChanged: function() {
        this.pathChanged()
    },
    ig: function(a) {
        var b = this.get("path"),
            c = a.Mb(this.map.get("resolution")),
            d = [],
            f,
            g,
            h;
        f = 0;
        for (g = b.length; f < g; f += 1) h = this.map.zb(b[f]).add(c),
            d.push(this.map.qe(h));
        0 < d.length && this.set("path", d);
        if (this.Eo && 0 < this.Eo.length) for (f = 0, b = this.Eo.length; f < b; f += 1) this.Eo[f].ig(a);
        this.hC.k("movepoly", {
            yw: c
        })
    },
    Rj: function(a) {
        this.get("options");
        return this.Fs() ? this.xz(a) : this.As(a)
    },
    Fs: function() {
        var a = this.get("options");
        return a && !!a.geodesic
    },
    getStrokeWeight: function() {
        return this.get("options").strokeWeight
    },
    xz: function(a) {
        if (!a || !a.length) return [];
        var b, c = [],
            d,
            f,
            g = [],
            h,
            k = this.map.get("resolution"),
            l = this.get("options").geodesicInterpolatePixelWidth || 17;
        c.push(a[0]);
        g.push(this.$n(a[0]));
        d = 1;
        for (f = a.length; d < f; d += 1) h = this.$n(a[d]),
            b = Math.round(Math.abs(h[0] - g[g.length - 1][0]) / k),
            b = Math.min(31, Math.round(b / l), Math.round(Math.abs(a[d - 1].r - a[d].r))),
            b = J.B.ND(a[d - 1], a[d], b),
            c.push.apply(c, b),
            g.push.apply(g, this.As(b)),
            c.push(a[d]),
            g.push(h);
        return g
    },
    em: function(a) {
        var b = [],
            c = [],
            d,
            f,
            g,
            h,
            k,
            l;
        a = a.ta;
        a instanceof J.R.zi ? l = [a] : a instanceof J.R.sn && (l = a.Rc);
        a = [];
        var m = this.map.get("rotation"),
            b = this.map.get("size");
        d = Math.PI * m / 180;
        var m = (Math.abs(b.width * Math.cos(d)) + Math.abs(b.height * Math.sin(d))) / 2,
            n = (Math.abs(b.width * Math.sin(d)) + Math.abs(b.height * Math.cos(d))) / 2;
        d = 0;
        for (f = l.length; d < f; d += 1) if (g = l[d].Pa, g.length) for (h = 0, k = g.length; h < k; h += 1) if (b = g[h], b = this.ob(b), b[0] = Math.round(b[0] + m), b[1] = Math.round(b[1] + n), 0 === h) c[0] = NaN,
            c[1] = NaN,
            a.push("M" + b[0] + " " + b[1]);
        else if (b[0] !== c[0] || b[1] !== c[1]) a.push("L" + b[0] + " " + b[1]),
            c[0] = b[0],
            c[1] = b[1];
        return a
    },
    Nh: function() {
        if (this.map && !this.t) {
            var a = this.map,
                b = this.get("path"),
                b = this.t = new J.ge({
                    name: "polyline-" + J.e.Cb(this),
                    zIndex: this.get("options").zIndex || 1,
                    map: a,
                    ta: new J.R.zi(this.Rj(b)),
                    style: this.get("options")
                });
            b.Ih = this;
            this.D("resolution", a);
            this.D("center", a);
            this.D("coords", b);
            this.D("style", b);
            b.Hc(["noSelect", "visible", "zIndex", "strokeWeight", "isOutline"], this)
        }
    },
    pathChanged: function() {
        var a = this.t,
            b = this.get("path");
        a && (this.set("coords", this.Rj(b)), "canvas" !== this.map.get("renderer") && a.T ? (b = this.em(a), J.f.dg || b.push("e"), b = b.join(" "), 0 === b.length && a.T ? (a.T.Wb.parentNode.removeChild(a.T.Wb), a.T.Aa.parentNode && a.T.Aa.parentNode.removeChild(a.T.Aa), a.T = null) : J.f.dg ? (a.T.Wb.setAttribute("d", b), a.T.Aa && a.T.Aa.setAttribute("d", b)) : (a.T.Wb.path = b, a.T.Aa && (a.T.Aa.path = b))) : this.set("display"))
    },
    Eh: function() {
        this.Fs() && this.pathChanged()
    },
    visibleChanged: function() {
        this.t && (this.t.T ? this.get("visible") ? (this.t.T.Wb.style.display = "block", this.t.T.Aa && (this.t.T.Aa.style.display = "block")) : (this.t.T.Wb.style.display = "none", this.t.T.Aa && (this.t.T.Aa.style.display = "none")) : this.set("display"))
    },
    optionsChanged: function() {
        this.t && (this.t.style = this.get("options"), this.t.zIndex = this.get("options").zIndex, this.t.Ug(), this.t.T && (this.t.T.Wb.parentNode && this.t.T.Wb.parentNode.removeChild(this.t.T.Wb), this.t.T.Aa && this.t.T.Aa.parentNode && this.t.T.Aa.parentNode.removeChild(this.t.T.Aa)));
        this.set("display")
    }
});
J.ba.Pc = J.ba.lh.extend({
    o: function(a, b) {
        arguments.callee.Ja.apply(this, arguments);
        this.gC = a;
        this.D("options", a);
        this.D("path", a);
        this.Nh();
        this.D("display", b)
    },
    ig: function(a) {
        var b = this.get("path");
        a = a.Mb(this.map.get("resolution"));
        var c = [],
            d,
            f;
        b.length && b[0] instanceof J.B && (b = [b], f = !0);
        for (var g = 0,
                 h = b.length; g < h; g += 1) {
            for (var k = b[g], l = [], m = 0, n = k.length; m < n; m += 1) d = this.map.zb(k[m]).add(a),
                l.push(this.map.qe(d));
            c.push(l)
        }
        0 < c.length && this.set("path", f ? c[0] : c);
        this.gC.k("movepoly", {
            yw: a
        })
    },
    Rj: function(a) {
        a.length && a[0] instanceof J.B && (a = [a]);
        for (var b, c, d = [], f, g = this.map, h = 0; h < a.length; h += 1) {
            var k = a[h];
            f = [];
            b = 0;
            for (c = k.length; b < c; b += 1) {
                var l = g.zb(k[b]);
                f.push([l.x, l.y])
            }
            d.push(f)
        }
        return d
    },
    Nh: function() {
        if (this.map && !this.t) {
            var a = this.map,
                b = this.get("path"),
                b = this.t = new J.ge({
                    name: "polygon-" + J.e.Cb(this),
                    zIndex: this.get("options").zIndex || 1,
                    map: a,
                    ta: new J.R.Pc(this.Rj(b)),
                    style: this.get("options")
                });
            b.Ih = this;
            this.D("resolution", a);
            this.D("center", a);
            this.D("coords", b);
            this.D("style", b);
            b.Hc(["visible", "zIndex", "strokeWeight"], this)
        }
    },
    pathChanged: function() {
        var a = this.t,
            b = this.get("path");
        a && (this.set("coords", this.Rj(b)), a.Pe = !0, "canvas" !== this.map.get("renderer") && a.H ? (b = this.fm(a), 0 === b.length ? (a.H.parentNode.removeChild(a.H), a.H = null) : J.f.dg ? a.H.setAttribute("d", b.join(" ")) : (b.push("e"), a.H.path = b.join(" "))) : this.set("display"))
    },
    getStrokeWeight: function() {
        return this.get("options").strokeWeight
    },
    visibleChanged: function() {
        this.t && (this.t.H ? this.get("visible") ? this.t.H.style.display = "block": this.t.H.style.display = "none": this.set("display"))
    },
    optionsChanged: function() {
        this.t && (this.t.style = this.get("options"), this.t.zIndex = this.get("options").zIndex, this.t.Ug());
        this.set("display")
    },
    fm: function(a) {
        var b = [NaN, NaN, 0],
            c = [NaN, NaN],
            d,
            f,
            g,
            h,
            k,
            l,
            m,
            n = this.map.get("rotation"),
            q = this.map.get("size");
        f = Math.PI * n / 180;
        n = (Math.abs(q.width * Math.cos(f)) + Math.abs(q.height * Math.sin(f))) / 2;
        q = (Math.abs(q.width * Math.sin(f)) + Math.abs(q.height * Math.cos(f))) / 2;
        a = a.ta;
        a instanceof J.R.Pc ? d = [a] : a instanceof J.R.tn && (d = a.Rc);
        var r = [];
        a = 0;
        for (f = d.length; a < f; a += 1) if (b = d[a], g = b.ae, h = g.length, 0 < h) for (var s = 0; s < h; s += 1) {
            var t;
            k = g[s].Pa;
            l = 0;
            for (m = k.length; l < m; l += 1) if (b = k[l], b = this.ob(b), b[0] = Math.ceil(b[0] + n), b[1] = Math.ceil(b[1] + q), 0 === l) c[0] = NaN,
                c[1] = NaN,
                t = b,
                r.push("M" + b[0] + " " + b[1]);
            else if (b[0] !== c[0] || b[1] !== c[1]) r.push("L" + b[0] + " " + b[1]),
                c = b;
            t && r.push("L" + t[0] + " " + t[1])
        }
        return r
    }
});
J.ba.tg = J.ba.lh.extend({
    o: function(a, b) {
        arguments.callee.Ja.apply(this, arguments);
        this.fC = a;
        this.D("center", a);
        this.D("draggable", a);
        this.D("radius", a);
        this.D("options", a);
        this.Nh();
        this.D("display", b)
    },
    ig: function(a) {
        var b = this.get("center");
        a = a.Mb(this.map.get("resolution"));
        var c = this.map.zb(b).add(a);
        b instanceof J.B ? this.set("center", this.map.qe(c)) : this.set("center", c);
        this.fC.k("movepoly", {
            yw: a
        })
    },
    Nh: function() {
        if (this.map && !this.t) {
            var a = this.map,
                b = a.zb(this.get("center")),
                b = this.t = new J.ge({
                    io: !0,
                    name: "circle-" + J.e.Cb(this),
                    zIndex: this.get("options").zIndex || 1,
                    map: a,
                    ta: new J.R.fd([b.x, b.y]),
                    style: this.get("options")
                });
            b.Ih = this;
            this.D("resolution", a);
            this.D("coords", b);
            this.D("style", b);
            b.D("visible", this, !0);
            b.Hc(["radius", "center", "resolution", "zIndex", "strokeWeight"], this)
        }
    },
    getStrokeWeight: function() {
        return this.get("options").strokeWeight
    },
    centerChanged: function() {
        var a = this.t,
            b = this.map.zb(this.get("center"));
        a && (a.ta.Pa = [b.x, b.y], this.set("coords", [b.x, b.y]), this.Pe = !0, a.H ? this.Hw() : this.set("display"))
    },
    visibleChanged: function() {
        this.t && (this.t.H ? this.get("visible") ? this.t.H.style.display = "block": this.t.H.style.display = "none": this.set("display"))
    },
    optionsChanged: function() {
        this.t && (this.t.style = this.get("options"), this.t.zIndex = this.get("options").zIndex, this.t.Ug(), this.t.Pe = !0, this.set("display"))
    },
    Xo: function(a) {
        var b = [],
            c = [],
            d,
            c = a.ta;
        c instanceof J.R.fd && (d = [c]);
        var c = this.map.get("crs").Ve(Math.floor(this.map.get("zoom"))),
            f = this.map.get("rotation"),
            b = this.map.get("size"),
            g = Math.PI * f / 180,
            f = (Math.abs(b.width * Math.cos(g)) + Math.abs(b.height * Math.sin(g))) / 2,
            g = (Math.abs(b.width * Math.sin(g)) + Math.abs(b.height * Math.cos(g))) / 2,
            b = this.ob(d[0].Pa);
        b[0] = Math.round(b[0] + f);
        b[1] = Math.round(b[1] + g);
        a = a.get("remain") ? 5.23 : this.get("radius") / (c * Math.cos(Math.PI * this.get("center").w / 180));
        return c = ["M", b[0], b[1] - a, "A", a, a, 0, 1, 1, b[0] - 0.01, b[1] - a, "Z"].join(" ")
    },
    Hw: function() {
        var a = this.t,
            b = this.get("radius");
        if ("canvas" !== this.map.get("renderer") && a.H) if (J.f.dg) b = this.Xo(a),
            a.H.setAttribute("d", b);
        else {
            b = this.map.get("crs").Ve(Math.floor(this.map.get("zoom")));
            b = this.get("radius") / (b * Math.cos(Math.PI * this.get("center").w / 180));
            a.H.style.width = Math.round(2 * b);
            a.H.style.height = Math.round(2 * b);
            var c = this.map.get("size").width / 2,
                d = this.map.get("size").height / 2,
                f = this.ob(a.ta.Pa);
            f[0] = Math.round(f[0] + c);
            f[1] = Math.round(f[1] + d);
            a.H.style.top = Math.round(f[1] - b);
            a.H.style.left = Math.round(f[0] - b)
        } else this.set("display")
    },
    radiusChanged: function() {
        var a = this.t,
            b = this.get("radius");
        a && (a.Pe = !0, a.k("rad", {
            li: b
        }), this.Hw())
    }
});